package com.itheima.example.consumer;

import com.itheima.example.common.model.User;
import com.itheima.example.common.service.UserService;
import com.itheima.weirpc.bootstrap.ConsumerBootstrap;
import com.itheima.weirpc.proxy.ServiceProxyFactory;


/**
 * ClassName: ConsumerExample
 * Package: com.itheima.example.consumer
 * Description:
 *          创建ConsumerExample作为扩展后RPC项目的示例消费者类，测试配置文件读取
 * @Author 看到风
 * @Create 2024/11/23 19:24
 * @Version 1.0
 */
public class ConsumerExample {
    public static void main(String[] args) {
        //服务提供者初始化
        ConsumerBootstrap.init();


////        RpcConfig rpc = ConfigUtils.loadConfig(RpcConfig.class,"rpc");
////        System.out.println(rpc);
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setName("weihe");
        //调用
        User newUser = userService.getUser(user);

        if(newUser!=null){
            System.out.println(newUser.getName());
        }
        else{
            System.out.println("user == null");
        }

    }
}
